<?php
/**
*	Begin Recent Posts Custom Widgets
*   OK TT & Mannat
**/
class Custom_Recent_Posts extends WP_Widget {
	function Custom_Recent_Posts() {
		$widget_ops = array('classname' => 'Custom_Recent_Posts', 'description' => 'The recent posts with thumbnails' );
		$this->WP_Widget('Custom_Recent_Posts', 'Custom Recent Posts', $widget_ops);
	}

	function widget($args, $instance) {
		extract($args, EXTR_SKIP);

		echo $before_widget;
		$items = empty($instance['items']) ? ' ' : apply_filters('widget_title', $instance['items']);
		
		if(!is_numeric($items))
		{
			$items = 3;
		}
		
		if(!empty($items))
		{
		 				  
			tt_posts('recent', $items, TRUE);
		}
		
		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['items'] = strip_tags($new_instance['items']);

		return $instance;
	}

	function form($instance) {
		$instance = wp_parse_args( (array) $instance, array( 'items' => '') );
		$items = strip_tags($instance['items']);
		

?>
			<p><label for="<?php echo $this->get_field_id('items'); ?>">Items (default 3): <input class="widefat" id="<?php echo $this->get_field_id('items'); ?>" name="<?php echo $this->get_field_name('items'); ?>" type="text" value="<?php echo esc_attr($items); ?>" /></label></p>
<?php
	}
}

register_widget('Custom_Recent_Posts');

/**
*	End Recent Posts Custom Widgets
**/

/**
* BEGIN HTML WIDGET
**/

class Custom_Html_Display extends WP_Widget{
	  function Custom_Html_Display(){
	  		   $widget_ops=array('classname' => 'Custom_Html_Display', 'description' => 'Display HTML');
			   $this->WP_Widget('Custom_Html_Display', 'Custom Html Display', $widget_ops);
	  }
	  function widget($args, $instance){
	  		   extract($args, EXTR_SKIP);
        		if ( is_active_widget( false, false, $this->id_base, true ) ) {
                	wp_enqueue_script('prettyPhoto');
                }			   
			   echo $before_widget;
			   $title=empty($instance['title']) ? '' : $instance['title'];
			   $content=empty($instance['content']) ? '' : $instance['content'];
			   
			   ?>
			   <h3><span><?php echo $title ; ?></span></h3>
			   <?php
			   if(!empty($content))
			   {
			   ?>
			   
			   <p><?php echo $content ?></p>
			   <?php
			   }
			   else
			   {
			   echo 'You must add Html content';
			   }
			   echo $after_widget;
	  }
    function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['content'] = $new_instance['content'];

		return $instance;
	}
	function form($instance) {
	$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'content' => '') );
		$title = strip_tags($instance['title']);
		$content = $instance['content'];
		?>
		<p><label for="<?php echo $this->get_field_id('title'); ?>">Title : <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('content'); ?>">Title : <textarea class="widefat" id="<?php echo $this->get_field_id('content'); ?>" name="<?php echo $this->get_field_name('content'); ?>" type="text" value="" ><?php echo esc_attr($content); ?></textarea></label></p>

		<?php
	}
}
register_widget('Custom_Html_Display');
/**
*	Begin Category Posts Custom Widgets
**/

class Custom_Cat_Posts extends WP_Widget {
	function Custom_Cat_Posts() {
		$widget_ops = array('classname' => 'Custom_Cat_Posts', 'description' => 'Display category\'s post' );
		$this->WP_Widget('Custom_Cat_Posts', 'Custom Category Posts', $widget_ops);
	}

	function widget($args, $instance) {
		extract($args, EXTR_SKIP);

		echo $before_widget;
		$cat_id = empty($instance['cat_id']) ? 0 : $instance['cat_id'];
		$items = empty($instance['items']) ? 0 : $instance['items'];
		
		if(empty($items))
		{
			$items = 5;
		}
		
		if(!empty($cat_id))
		{
			tt_cat_posts($cat_id, $items);
		}

		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['cat_id'] = strip_tags($new_instance['cat_id']);
		$instance['items'] = strip_tags($new_instance['items']);

		return $instance;
	}

	function form($instance) {
		$instance = wp_parse_args( (array) $instance, array( 'cat_id' => '', 'items' => '') );
		$cat_id = strip_tags($instance['cat_id']);
		$items = strip_tags($instance['items']);
		
		$categories = get_categories('hide_empty=0&orderby=name');
		$wp_cats = array(
			0		=> "Choose a category"
		);
		foreach ($categories as $category_list ) {
			$wp_cats[$category_list->cat_ID] = $category_list->cat_name;
		}

?>
			
			<p><label for="<?php echo $this->get_field_id('cat_id'); ?>">Category: 
				<select  id="<?php echo $this->get_field_id('cat_id'); ?>" name="<?php echo $this->get_field_name('cat_id'); ?>">
				<?php
					foreach($wp_cats as $wp_cat_id => $wp_cat)
					{
				?>
						<option value="<?php echo $wp_cat_id; ?>" <?php if(esc_attr($cat_id) == $wp_cat_id) { echo 'selected="selected"'; } ?>><?php echo $wp_cat; ?></option>
				<?php
					}
				?>
				</select>
			</label></p>
			
			<p><label for="<?php echo $this->get_field_id('items'); ?>">Items (default 5): <input class="widefat" id="<?php echo $this->get_field_id('items'); ?>" name="<?php echo $this->get_field_name('items'); ?>" type="text" value="<?php echo esc_attr($items); ?>" /></label></p>
<?php
	}
}

register_widget('Custom_Cat_Posts');

/**
*	End Category Posts Custom Widgets
**/



/**
*	Begin Popular Posts Custom Widgets
**/

class Custom_Popular_Posts extends WP_Widget {
	function Custom_Popular_Posts() {
		$widget_ops = array('classname' => 'Custom_Popular_Posts', 'description' => 'The popular posts with thumbnails' );
		$this->WP_Widget('Custom_Popular_Posts', 'Custom Popular Posts', $widget_ops);
	}

	function widget($args, $instance) {
		extract($args, EXTR_SKIP);

		echo $before_widget;
		$items = empty($instance['items']) ? ' ' : apply_filters('widget_title', $instance['items']);
		
		if(!is_numeric($items))
		{
			$items = 3;
		}
		
		if(!empty($items))
		{
			tt_posts('popular', $items, TRUE);
		}
		
		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['items'] = strip_tags($new_instance['items']);

		return $instance;
	}

	function form($instance) {
		$instance = wp_parse_args( (array) $instance, array( 'items' => '') );
		$items = strip_tags($instance['items']);

?>
			<p><label for="<?php echo $this->get_field_id('items'); ?>">Items (default 3): <input class="widefat" id="<?php echo $this->get_field_id('items'); ?>" name="<?php echo $this->get_field_name('items'); ?>" type="text" value="<?php echo esc_attr($items); ?>" /></label></p>
<?php
	}
}

register_widget('Custom_Popular_Posts');

/**
*	End Popular Posts Custom Widgets
**/

/**
*	Begin Portfolios Custom Widgets
**/

/*class Custom_Portfolios extends WP_Widget {
	function Custom_Portfolios() {
		$widget_ops = array('classname' => 'Custom_Portfolios', 'description' => 'Portfolio items widget' );
		$this->WP_Widget('Custom_Portfolios', 'Custom Portfolios', $widget_ops);
	}

	function widget($args, $instance) {
		extract($args, EXTR_SKIP);

		echo $before_widget;
		$items = empty($instance['items']) ? ' ' : apply_filters('widget_title', $instance['items']);
		
		if(!is_numeric($items))
		{
			$items = 3;
		}
		
		if(!empty($items))
		{
			$pp_portfolio_sort = get_option('pp_portfolio_sort'); 
			if(empty($pp_portfolio_sort))
			{
				$pp_portfolio_sort = 'ASC';
			}
				
			$portfolio_items = get_posts('numberposts='.$items.'&order='.$pp_portfolio_sort.'&orderby=date&post_type=portfolios');
			
			if(isset($portfolio_items) && !empty($portfolio_items))
			{
				echo '<h2 class="widgettitle">Portfolio</h2>';
			
				foreach($portfolio_items as $key => $portfolio_item)
				{
					$image_url = '';
								
					if(has_post_thumbnail($portfolio_item->ID, 'large'))
					{
					    $image_id = get_post_thumbnail_id($portfolio_item->ID);
					    $image_url = wp_get_attachment_image_src($image_id, 'large', true);
					}
					
					$permalink_url = get_permalink($portfolio_item->ID);
													
					$word_count = 400;
					if(!empty($image_url[0]))
					{
						$word_count = 100;
					}
?>

					<div class="portfolio_grid">

<?php					
					if(!empty($image_url))
					{
?>					
						<div class="portfolio_image">
							<a href="<?php echo $permalink_url; ?>">
								<img src="<?php get_stylesheet_directory_uri(); ?>/timthumb.php?src=<?php echo $image_url[0]?>&amp;h=200&amp;w=250&amp;zc=1" alt="" class="img_nofade alignleft"/>
							</a>
						</div>
<?php				
					}
?>
						<div class="portfolio_desc">
							<h6 class="cufon"><a href="<?php echo $permalink_url; ?>"><?php echo $portfolio_item->post_title?></a></h6>
							<?php echo pp_substr(strip_tags(strip_shortcodes($portfolio_item->post_content)), $word_count); ?>
						</div>
					</div>
					<br class="clear"/>

<?php
				}
			}
		}
		
		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['items'] = strip_tags($new_instance['items']);

		return $instance;
	}

	function form($instance) {
		$instance = wp_parse_args( (array) $instance, array( 'items' => '' ) );
		$items = strip_tags($instance['items']);
		$bg_color = strip_tags($instance['bg_color']);
		if(empty($bg_color))
		{
			$bg_color = 'black';
		}

?>
			<p><label for="<?php echo $this->get_field_id('items'); ?>">Items (default 3): <input class="widefat" id="<?php echo $this->get_field_id('items'); ?>" name="<?php echo $this->get_field_name('items'); ?>" type="text" value="<?php echo esc_attr($items); ?>" /></label></p>
<?php
	}
}

register_widget('Custom_Portfolios');*/

/**
*	End Portfolios Posts Custom Widgets
**/

/**
*	Begin Twitter Feed Custom Widgets
**/

class Custom_Twitter extends WP_Widget {
	function Custom_Twitter() {
		$widget_ops = array('classname' => 'Custom_Twitter', 'description' => 'Display your recent Twitter feed' );
		$this->WP_Widget('Custom_Twitter', 'Custom Twitter', $widget_ops);
	}

	function widget($args, $instance) {
		extract($args, EXTR_SKIP);

		echo $before_widget;
		$twitter_username = empty($instance['twitter_username']) ? ' ' : apply_filters('widget_title', $instance['twitter_username']);
		$title = $instance['title'];
		$items = empty($instance['items']) ? ' ' : apply_filters('widget_title', $instance['items']);
		
		if(!is_numeric($items))
		{
			$items = 5;
		}
		
		if(empty($title))
		{
			$title = 'Recent Tweets';
		}
		
		if(!empty($items) && !empty($twitter_username))
		{
			// Begin get user timeline
			require_once (API_DIR . "/function/api_twitter.php");
			wp_enqueue_script('tweet');
			$obj_twitter = new Twitter($twitter_username); 
			$tweets = $obj_twitter->get($items);
			if(!empty($tweets))
			{
				echo '<h3 class="widgettitle"><span>'.$title.'</span></h3>';
				echo '<div class="tweet query">';
				echo '<ul class="tweet_list">';
				
				foreach($tweets as $tweet)
				{
					echo '<li class="tweet_even">';
					
					if(isset($tweet[0]))
					{
						echo '<span class="tweet_time"><a href="'.$tweet[2].'">'.$tweet[1].'</a></span>';
						echo $tweet[0];
					}
					
					echo '</li>';
				}
				
				echo '</ul>';
				echo '</div>';
				echo '<div class="twitter_arrow"></div>';
				echo '<div class="twitter_username"><img src="'.get_stylesheet_directory_uri().'/images/icon_twitter_bird.png" class="middle" alt="" style="margin-right:5px"/>Follow <a href="http://twitter.com/'.$twitter_username.'">@'.$twitter_username.'</a></div>';
			}
		}
		
		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['items'] = strip_tags($new_instance['items']);
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['twitter_username'] = strip_tags($new_instance['twitter_username']);

		return $instance;
	}

	function form($instance) {
		$instance = wp_parse_args( (array) $instance, array( 'items' => '', 'twitter_username' => '', 'title' => '') );
		$items = strip_tags($instance['items']);
		$twitter_username = strip_tags($instance['twitter_username']);
		$title = strip_tags($instance['title']);

?>
			<p><label for="<?php echo $this->get_field_id('twitter_username'); ?>">Twitter Username: <input class="widefat" id="<?php echo $this->get_field_id('twitter_username'); ?>" name="<?php echo $this->get_field_name('twitter_username'); ?>" type="text" value="<?php echo esc_attr($twitter_username); ?>" /></label></p>
			
			<p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>

			<p><label for="<?php echo $this->get_field_id('items'); ?>">Items (default 5): <input class="widefat" id="<?php echo $this->get_field_id('items'); ?>" name="<?php echo $this->get_field_name('items'); ?>" type="text" value="<?php echo esc_attr($items); ?>" /></label></p>
<?php
	}
}

register_widget('Custom_Twitter');

/**
*	End Twitter Feed Custom Widgets
**/

/**
*	Begin Contact Form Custom Widgets
**/

class Custom_Contact_Form extends WP_Widget {
	function Custom_Contact_Form() {
		$widget_ops = array('classname' => 'Custom_Contact_Form', 'description' => 'Display contact form' );
		$this->WP_Widget('Custom_Contact_Form', 'Custom Contact Form', $widget_ops);
	}

	function widget($args, $instance) {
		extract($args, EXTR_SKIP);

		echo $before_widget;
		$title = empty($instance['title']) ? '' : apply_filters('widget_title', $instance['title']);
		
		if(empty($title))
		{
			$title = 'Contact Us';
		}
		wp_enqueue_script("validate");
		$pp_contact_email = get_option('pp_contact_email');
		
		echo '<h3><span>'.$title.'</span></h3>';
?>

			<form id="wg_contact_form" method="post" action="<?php echo API_URI; ?>/api_send_email.php">
				<input type="hidden" id="contact_email" name="contact_email" value="<?php echo get_theme_option('contact','email'); ?>"/>
				<p>
				    <input id="wg_your_name" name="name" placeholder="Name ..." title="Name" type="text" style="width:90%"/>
				</p>
				<p>
				    <input id="wg_email" name="email" placeholder="Email ..." type="text" title="Email" style="width:90%"/>
				</p>
				<p>
				    <textarea id="wg_message" name="message" placeholder="Message ..." title="Message" rows="2" cols="10" style="width:90%;height:60px"></textarea>
				</p>
				<p>
				    <input type="submit" class="submit" value="Send Message"/><br/>
				</p>
			</form>
			<div id="reponse_msg"></div>
		
<?php
echo'<script type="text/javascript">
	jQuery(document).ready(function(){ 
		jQuery("#wg_contact_form").validate({
			meta: "validate",
			submitHandler: function (form) {
				var s_name=jQuery("#wg_your_name").val();
				var s_email=jQuery("#wg_email").val();
				var s_comment=jQuery("#wg_message").val();';
echo '
	  			data={
					 action : \'wgcontact\',
					 name: s_name,
					 email: s_email,
					 message: s_comment';		 
echo'				};';				
echo '
				var ajax_url = "wp-admin/admin-ajax.php";
				
				jQuery.post(ajax_url,data,
				function(result){
                  alert(result);
                });
				return false;
				},
				
				
			/* */
			rules: {
				name: "required",

				email: { // compound rule
					required: true,
					email: true
				},
				message: {
					required: true
				}
			},
			messages: {
				name: "*",
				email: {
					required: "*",
					email: "*"
				},
				message: "*"
			},
		});
	});		
</script>';	
		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);

		return $instance;
	}

	function form($instance) {
		$instance = wp_parse_args( (array) $instance, array( 'items' => '','title'=>'') );
		$title = strip_tags($instance['title']);

?>
			
			<p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
<?php
	}
}

register_widget('Custom_Contact_Form');

/**
*	End Contact Form Custom Widgets
**/

/**
*	Begin Map Custom Widgets
*   OK MAP
**/

class Custom_Map extends WP_Widget {
	function Custom_Map() {
		$widget_ops = array('classname' => 'Custom_Map', 'description' => 'Display map' );
		$this->WP_Widget('Custom_Map', 'Custom Map', $widget_ops);
	}
	function widget($args, $instance) {
		extract($args, EXTR_SKIP);

		echo $before_widget;
		$title = empty($instance['title']) ? 'Map' : $instance['title'];
		$width = empty($instance['width']) ? 180 : $instance['width'];
		$height = empty($instance['height']) ? 240 : $instance['height'];
		$lat = empty($instance['lat']) ? 0 : $instance['lat'];
		$long = empty($instance['long']) ? 0 : $instance['long'];
		
		$custom_id = time().rand();
       if ( is_active_widget(false, false, $this->id_base,true) ) {
      		wp_enqueue_script('google_map');
              wp_enqueue_script('gmap');
            };	
		echo '<h2 class="widgettitle">'.$title.'</h2>';
		
		$marker = '';
		if(!empty($lat) && !empty($long))
		{
			$marker = '{ zoom: 12, markers: [ { latitude: '.$lat.', longitude: '.$long.' } ] }';
		}
		  
?>

			<div id="map<?php echo $custom_id; ?>" style="width:<?php echo $width; ?>px;height:<?php echo $height; ?>px;margin-bottom:15px"></div>
			<script>
				jQuery(document).ready(function(){ 
					jQuery("#map<?php echo $custom_id; ?>").gMap(<?php echo $marker; ?>);
				});
			</script>
		
<?php
		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['width'] = strip_tags($new_instance['width']);
		$instance['height'] = strip_tags($new_instance['height']);
		$instance['lat'] = strip_tags($new_instance['lat']);
		$instance['long'] = strip_tags($new_instance['long']);

		return $instance;
	}

	function form($instance) {
		$instance = wp_parse_args( (array) $instance, array( 'items' => '', 'title' => '', 'width' => '', 'height' => '', 'lat' => '', 'long' => '') );
		$title = strip_tags($instance['title']);
		$width = strip_tags($instance['width']);
		$height = strip_tags($instance['height']);
		$lat = strip_tags($instance['lat']);
		$long = strip_tags($instance['long']);

?>
			
			<p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
			
			<p><label for="<?php echo $this->get_field_id('width'); ?>">Width: <input class="widefat" id="<?php echo $this->get_field_id('width'); ?>" name="<?php echo $this->get_field_name('width'); ?>" type="text" value="<?php echo esc_attr($width); ?>" /></label></p>
			
			<p><label for="<?php echo $this->get_field_id('height'); ?>">Height: <input class="widefat" id="<?php echo $this->get_field_id('height'); ?>" name="<?php echo $this->get_field_name('height'); ?>" type="text" value="<?php echo esc_attr($height); ?>" /></label></p>
			
			<p><label for="<?php echo $this->get_field_id('lat'); ?>">Latitude (<a href="http://www.tech-recipes.com/rx/5519/the-easy-way-to-find-latitude-and-longitude-values-in-google-maps/">Find here</a>): <input class="widefat" id="<?php echo $this->get_field_id('lat'); ?>" name="<?php echo $this->get_field_name('lat'); ?>" type="text" value="<?php echo esc_attr($lat); ?>" /></label></p>
			
			<p><label for="<?php echo $this->get_field_id('long'); ?>">Longitude (<a href="http://www.tech-recipes.com/rx/5519/the-easy-way-to-find-latitude-and-longitude-values-in-google-maps/">Find here</a>): <input class="widefat" id="<?php echo $this->get_field_id('long'); ?>" name="<?php echo $this->get_field_name('long'); ?>" type="text" value="<?php echo esc_attr($long); ?>" /></label></p>
<?php
	}
}

register_widget('Custom_Map');

/**
*	End Map Custom Widgets
**/



/**
*	Begin Flickr Feed Custom Widgets
**/

class Custom_Flickr extends WP_Widget {
	function Custom_Flickr() {
		$widget_ops = array('classname' => 'Custom_Flickr', 'description' => 'Display your recent Flickr photos' );
		$this->WP_Widget('Custom_Flickr', 'Custom Flickr', $widget_ops);
		
	}

	function widget($args, $instance) {
		extract($args, EXTR_SKIP);
    	
		
		if ( is_active_widget(false, false, $this->id_base,true) ) {
         	wp_enqueue_script('prettyPhoto');  
      		};	
		echo $before_widget;
		$flickr_id = empty($instance['flickr_id']) ? ' ' : apply_filters('widget_title', $instance['flickr_id']);
		$title = $instance['title'];
		$items = $instance['items'];
		
		if(!is_numeric($items))
		{
			$items = 9;
		}
		
		if(empty($title))
		{
			$title = 'Photostream';
		}
		
		if(!empty($items) && !empty($flickr_id))
		{
			$photos_arr = get_flickr(array('type' => 'user', 'id' => $flickr_id, 'items' => $items));
			
			if(!empty($photos_arr))
			{
				echo '<h3><span>'.$title.'</span></h3>';
				
				echo '<ul class="widget-flickr">';
				
				foreach($photos_arr as $photo)
				{
					echo '<li class="flickr_badge_image">';
					echo '<a rel="prettyPhoto" class="zoom-icon" href="'.$photo['url'].'" title="'.$photo['title'].'"><img src="'.$photo['thumb_url'].'" alt="" class="img_nofade" /></a>';
					echo '</li>';
				}
				
				echo '</ul><div class="clearfix"></div>';
			}
		}
		
		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['items'] = strip_tags($new_instance['items']);
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['flickr_id'] = strip_tags($new_instance['flickr_id']);

		return $instance;
	}

	function form($instance) {
		$instance = wp_parse_args( (array) $instance, array( 'items' => '', 'flickr_id' => '', 'title' => '') );
		$items = strip_tags($instance['items']);
		$flickr_id = strip_tags($instance['flickr_id']);
		$title = strip_tags($instance['title']);

?>
			<p><label for="<?php echo $this->get_field_id('flickr_id'); ?>">Flickr ID <a href="http://idgettr.com/">Find your Flickr ID here</a>: <input class="widefat" id="<?php echo $this->get_field_id('flickr_id'); ?>" name="<?php echo $this->get_field_name('flickr_id'); ?>" type="text" value="<?php echo esc_attr($flickr_id); ?>" /></label></p>
			
			<p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>

			<p><label for="<?php echo $this->get_field_id('items'); ?>">Items (default 9): <input class="widefat" id="<?php echo $this->get_field_id('items'); ?>" name="<?php echo $this->get_field_name('items'); ?>" type="text" value="<?php echo esc_attr($items); ?>" /></label></p>
<?php
	}
}

register_widget('Custom_Flickr');

/**
*	End Flickr Feed Custom Widgets
**/

/**
*	Begin Testimonials Custom Widgets
**/

class Custom_Testimonial extends WP_Widget {
	function Custom_Testimonial() {
		$widget_ops = array('classname' => 'Custom_Testimonial', 'description' => 'Display customer testimonials' );
		$this->WP_Widget('Custom_Testimonial', 'Custom Testimonial', $widget_ops);
	}

	function widget($args, $instance) {
		extract($args, EXTR_SKIP);

		echo $before_widget;
		$title = $instance['title'];
		$message = $instance['message'];
		$from = $instance['from'];
		
		if(empty($title))
		{
			$title = 'Testimonial';
		}
		
		echo '<h3><span>'.$title.'</span></h3>';
		echo '<div class="testimonial_wrapper">'.do_shortcode($message).'</div>';
		echo '<div class="testimonial_arrow"></div>';
		echo '<div class="testimonial_name"><strong>'.$from.'</strong></div>';
		
		echo $after_widget;
	}

	function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['message'] = strip_tags($new_instance['message']);
		$instance['from'] = strip_tags($new_instance['from']);

		return $instance;
	}

	function form($instance) {
		$instance = wp_parse_args( (array) $instance, array( 'message' => '', 'title' => '', 'from' => '') );
		$message = strip_tags($instance['message']);
		$title = strip_tags($instance['title']);
		$from = strip_tags($instance['from']);

?>
			<p><label for="<?php echo $this->get_field_id('title'); ?>">Title: <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>

			<p><label for="<?php echo $this->get_field_id('message'); ?>">Message: <textarea class="widefat" id="<?php echo $this->get_field_id('message'); ?>" name="<?php echo $this->get_field_name('message'); ?>"><?php echo esc_attr($message); ?></textarea></label></p>
			
			<p><label for="<?php echo $this->get_field_id('from'); ?>">From: <input class="widefat" id="<?php echo $this->get_field_id('from'); ?>" name="<?php echo $this->get_field_name('from'); ?>" type="text" value="<?php echo esc_attr($from); ?>" /></label></p>
<?php
	}
}

register_widget('Custom_Testimonial');

/**
*	End Testimonials Custom Widgets
**/


/**
* BEGIN HTML WIDGET
**/
class Custom_Social extends WP_Widget{
	  function Custom_Social(){
	  		   $widget_ops=array('classname' => 'Custom_Social', 'description' => 'Custom Social');
			   $this->WP_Widget('Custom_Social', 'Custom Social', $widget_ops);
	  }
	  function widget($args, $instance){
	  		   extract($args, EXTR_SKIP);
			   echo $before_widget;
			   $title=$instance['title'];
			   $content=$instance['content'];
			   $facebook=$instance['facebook'];
			   $rss=$instance['rss'];
			   $yahoo=$instance['yahoo'];
			   $twitter=$instance['twitter'];
			   ?>
			   <h3><span><?php echo $title ; ?></span></h3>
			   <?php
			   if(!empty($content))
			   {
			   ?>
			   
			   <div><?php do_shortcode($content) ?></div>
			   <?php
			   }
			   else
			   {
			   echo 'You must add Html content';
			   }
			   ?>
			   <div class="social-icons">
			   		<ul>
                        <li><a class="tooltip" title="Facebook" href="<?php echo $facebook; ?>">facebook</a></li>
                        <li><a class="tooltip twitter" title="Twitter" href="<?php echo $twitter; ?>">facebook</a></li>
                        <li><a class="tooltip rss" title="RSS" href="<?php echo $twitter; ?>">RSS</a></li>
                        <li><a class="tooltip mail" title="Mail Us" href="<?php echo $yahoo; ?>">Mail</a></li>
                        
					</ul>
               </div>
			   <?php
			   echo $after_widget;
	  }
    function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['content'] = strip_tags($new_instance['content']);
        $instance['facebook'] = strip_tags($new_instance['facebook']);
        $instance['rss'] = strip_tags($new_instance['rss']);
		$instance['yahoo'] = strip_tags($new_instance['yahoo']);
        $instance['twitter'] = strip_tags($new_instance['twitter']);
		
		return $instance;
	}
	function form($instance) {
	$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'content' => '', 'facebook' => '', 'rss' => '', 'yahoo' => '', 'twitter' => '') );
    $title=strip_tags($instance['title']);
    $content=strip_tags($instance['content']);
    $facebook=strip_tags($instance['facebook']);
    $rss=strip_tags($instance['rss']);
    $yahoo=strip_tags($instance['yahoo']);
    $twitter=strip_tags($instance['twitter']);
		
		?>
		<p><label for="<?php echo $this->get_field_id('title'); ?>">Title : <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('content'); ?>">Content : <textarea class="widefat" id="<?php echo $this->get_field_id('content'); ?>" name="<?php echo $this->get_field_name('content'); ?>" type="text" value="" ><?php echo esc_attr($content); ?></textarea></label></p>
		<p><label for="<?php echo $this->get_field_id('facebook'); ?>">Facebook : <input class="widefat" id="<?php echo $this->get_field_id('facebook'); ?>" name="<?php echo $this->get_field_name('facebook'); ?>" type="text" value="<?php echo esc_attr($facebook); ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('rss'); ?>">Rss : <input class="widefat" id="<?php echo $this->get_field_id('rss'); ?>" name="<?php echo $this->get_field_name('rss'); ?>" type="text" value="<?php echo esc_attr($rss); ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('yahoo'); ?>">Yahoo : <input class="widefat" id="<?php echo $this->get_field_id('yahoo'); ?>" name="<?php echo $this->get_field_name('yahoo'); ?>" type="text" value="<?php echo esc_attr($yahoo); ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('twitter'); ?>">Twitter : <input class="widefat" id="<?php echo $this->get_field_id('twitter'); ?>" name="<?php echo $this->get_field_name('twitter'); ?>" type="text" value="<?php echo esc_attr($twitter); ?>" /></label></p>

		<?php
	}
}
register_widget('Custom_Social');
/**
* BEGIN HTML WIDGET
**/
class Custom_Quick_Contact extends WP_Widget{
	  function Custom_Quick_Contact(){
	  		   $widget_ops=array('classname' => 'Custom_Quick_Contact', 'description' => 'Custom Quick Contact');
			   $this->WP_Widget('Custom_Quick_Contact', 'Custom Quick Contact', $widget_ops);
	  }
	  function widget($args, $instance){
	  		   extract($args, EXTR_SKIP);
			   echo $before_widget;
			   $title=strip_tags($instance['title']);
			   $content=strip_tags($instance['content']);
			   $phone=strip_tags($instance['phone']);
			   $fax=strip_tags($instance['fax']);
			   $mail=strip_tags($instance['mail']);
			   $address=strip_tags($instance['address']);
			   
			   ?>
			   <h3><span><?php echo $title ; ?></span></h2>
			   <?php
			   if(!empty($content))
			   {
			   ?>
			   
			   <p><?php do_shortcode($content) ?></p>
			   <?php
			   }
			   else
			   {
			   echo 'You must add Html content';
			   }
			   ?>
			   <div class="contact-footer">
                    	<ul>
                            <li><span>Phone :</span> <?php echo $phone ;  ?></li>
                            <li><span>Fax :</span><?php echo $fax ;  ?></li>
                            <li><span>Email :</span> <a href="mailto:<?php echo $mail ;  ?>"><?php echo $mail ;  ?></a></li>
                            <li><span>Address :</span> <?php echo $address ;  ?></li>
                        </ul>
               </div>
			   <?php
			   echo $after_widget;
	  }
    function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['content'] = strip_tags($new_instance['content']);
        $instance['phone'] =strip_tags( $new_instance['phone']);
        $instance['fax'] = strip_tags($new_instance['fax']);
        $instance['mail'] = strip_tags($new_instance['mail']);
        $instance['address'] = strip_tags($new_instance['address']);
        return $instance;
	}
	function form($instance) {
        $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'content' => '', 'phone' => '', 'fax' => '', 'mail' => '', 'address' => '') );
        $title=strip_tags($instance['title']);
        $content=strip_tags($instance['content']);
        $phone=strip_tags($instance['phone']);
        $fax=strip_tags($instance['fax']);
        $mail=strip_tags($instance['mail']);
        $address=strip_tags($instance['address']);
		
		
		?>
		<p><label for="<?php echo $this->get_field_id('title'); ?>">Title : <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('content'); ?>">Content : <textarea class="widefat" id="<?php echo $this->get_field_id('content'); ?>" name="<?php echo $this->get_field_name('content'); ?>" type="text" value="" ><?php echo esc_attr($content); ?></textarea></label></p>
		<p><label for="<?php echo $this->get_field_id('phone'); ?>">Phone : <input class="widefat" id="<?php echo $this->get_field_id('phone'); ?>" name="<?php echo $this->get_field_name('phone'); ?>" type="text" value="<?php echo esc_attr($phone); ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('fax'); ?>">Fax : <input class="widefat" id="<?php echo $this->get_field_id('fax'); ?>" name="<?php echo $this->get_field_name('fax'); ?>" type="text" value="<?php echo esc_attr($fax); ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('mail'); ?>">Mail : <input class="widefat" id="<?php echo $this->get_field_id('mail'); ?>" name="<?php echo $this->get_field_name('mail'); ?>" type="text" value="<?php echo esc_attr($mail); ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('address'); ?>">Address : <input class="widefat" id="<?php echo $this->get_field_id('address'); ?>" name="<?php echo $this->get_field_name('address'); ?>" type="text" value="<?php echo esc_attr($address); ?>" /></label></p>

		<?php
	}
}
register_widget('Custom_Quick_Contact');
/**
* BEGIN HTML WIDGET
**/
class Custom_Quick_Contact_2 extends WP_Widget{
	  function Custom_Quick_Contact_2(){
	  		   $widget_ops=array('classname' => 'Custom_Quick_Contact_2', 'description' => 'Custom Quick Contact 2');
			   $this->WP_Widget('Custom_Quick_Contact_2', 'Custom Quick Contact 2', $widget_ops);
	  }
	  function widget($args, $instance){
	  		   extract($args, EXTR_SKIP);
			   echo $before_widget;
			   $title=strip_tags($instance['title']);
			   $content=strip_tags($instance['content']);
			   $phone=strip_tags($instance['phone']);
			   $fax=strip_tags($instance['fax']);
			   $mail=strip_tags($instance['mail']);
			   $website=strip_tags($instance['website']);
			   
			   ?>
			   <h3><span><?php echo $title ; ?></span></h2>
			   <?php
			   if(!empty($content))
			   {
			   ?>
			   
			   <p><?php echo do_shortcode($content) ?></p>
			   <?php
			   }
			   else
			   {
			   echo 'You must add Html content';
			   }
			   ?>
                    	<ul class="cont-txt">
                            <li class="phone">Phone :<?php echo $phone ;  ?></li>
                            <li class="fax">Fax :<?php echo $fax ;  ?></li>
                            <li class="email"><a href="mailto:<?php echo $mail; ?>">Email :<?php echo $mail ;  ?></a></li>
                            <li class="link-url"><a href="<?php $website ?>">Website : <?php echo $website ;  ?></a></li>
						</ul>
						<div class="clearfix"></div>
			   <?php
			   echo $after_widget;
	  }
    function update($new_instance, $old_instance) {
		$instance = $old_instance;
		$instance['title'] = strip_tags($new_instance['title']);
		$instance['content'] = strip_tags($new_instance['content']);
        $instance['phone'] =strip_tags( $new_instance['phone']);
        $instance['fax'] = strip_tags($new_instance['fax']);
        $instance['mail'] = strip_tags($new_instance['mail']);
        $instance['website'] = strip_tags($new_instance['website']);
		return $instance;
	}
	function form($instance) {
    	$instance = wp_parse_args( (array) $instance, array( 'title' => '', 'content' => '', 'phone' => '', 'fax' => '', 'mail' => '', 'website' => '') );
        $title=empty($instance['title']) ? '' : $instance['title'];
        $content=empty($instance['content']) ? '' : $instance['content'];
        $phone=empty($instance['phone']) ? '' : $instance['phone'];
        $fax=empty($instance['fax']) ? '' : $instance['fax'];
        $mail=empty($instance['mail']) ? '' : $instance['mail'];
        $website=empty($instance['website']) ? '' : $instance['website'];
		
		
		?>
		<p><label for="<?php echo $this->get_field_id('title'); ?>">Title : <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('content'); ?>">Content : <textarea class="widefat" id="<?php echo $this->get_field_id('content'); ?>" name="<?php echo $this->get_field_name('content'); ?>" type="text" value="" ><?php echo esc_attr($content); ?></textarea></label></p>
		<p><label for="<?php echo $this->get_field_id('phone'); ?>">Phone : <input class="widefat" id="<?php echo $this->get_field_id('phone'); ?>" name="<?php echo $this->get_field_name('phone'); ?>" type="text" value="<?php echo esc_attr($phone); ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('fax'); ?>">Fax : <input class="widefat" id="<?php echo $this->get_field_id('fax'); ?>" name="<?php echo $this->get_field_name('fax'); ?>" type="text" value="<?php echo esc_attr($fax); ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('mail'); ?>">Mail : <input class="widefat" id="<?php echo $this->get_field_id('mail'); ?>" name="<?php echo $this->get_field_name('mail'); ?>" type="text" value="<?php echo esc_attr($mail); ?>" /></label></p>
		<p><label for="<?php echo $this->get_field_id('website'); ?>">Website : <input class="widefat" id="<?php echo $this->get_field_id('website'); ?>" name="<?php echo $this->get_field_name('website'); ?>" type="text" value="<?php echo esc_attr($website); ?>" /></label></p>

		<?php
	}
}
register_widget('Custom_Quick_Contact_2');
?>